<{use class="frontend\assets\FancyBoxAsset"}>
<{FancyBoxAsset::register($this)|void}>
<{use class="frontend\assets\SwiperAsset"}>
<{SwiperAsset::register($this)|void}>

<div class="content margin_top">
    <header class="header fixed_top bg_mx_green"></header>
    <div class="swiper-container swiper-container-horizontal">
        <div class="swiper-wrapper">
            <{foreach $banner as $key => $row}>
            <div class="swiper-slide" style="width: 100%;">
                <a href="<{$row}>" class="fancybox" data-fancybox-group="gallery"><img src="<{$row}>"/></a>
            </div>
            <{/foreach}>
        </div>

        <div class="swiper-pagination swiper-pagination-clickable swiper-pagination-bullets">
            <{foreach $banner as $key => $row}>
            <span class="swiper-pagination-bullet"><{$key}></span>
            <{/foreach}>
        </div>
    </div>

    <div class="detail"></div>

    <script type="text/template" charset="utf-8" id='swipe_template'></script>
    <script type="text/template" charset="utf-8" id='detail_template'>
        <div class="bg_white margin_b_10">
            <div class="row padding_10_15">
                <div class="col_6">猪种：{{=it.type}}</div>
                <div class="col_6">入栏时间：{{=it.period}}</div>
                <div class="col_6">养殖户：{{=it.operator}}</div>
                <div class="col_6">领养人：{{=it.owner}}</div>
                <div class="col_6">状态：{{=it.status}}</div>
            </div>
        </div>
        <div class="row text_center bg_white margin_b_10 padding_10_15">

            {{if(it.oldstatus != 7){}}
            {{if(it.oldstatus==2 && it.oldstatus!=3){}}
            <div class="col_4 margin_b_10" onclick="location.href='<{url route='/business/person/new-put-inspection' pigid=$pigid}>'">
                <span class="label_mx_green padding_h_10">常规巡检</span>
            </div>
            {{}}}

            {{if(it.oldstatus!=3 && it.oldstatus!=6){}}
            <div class="col_4 margin_b_10" onclick="location.href='<{url route='/business/person/vaccine' pigid=$pigid}>'">
                <span class="label_mx_green padding_h_10">添加疫苗</span>
            </div>
            {{}}}
            {{if(it.oldstatus!=6){}}
            <div class="col_4 margin_b_10" onclick="location.href='<{url route='/business/person/cost' pigid=$pigid}>'">
                <span class="label_mx_green padding_h_10">添加成本</span>
            </div>
            {{}}}

            {{if(it.oldstatus!=3 && it.oldstatus!=6){}}
            <div class="col_4" onclick="location.href='<{url route='/business/person/pig-exception' pigid=$pigid}>'">
                <span class="label_mx_green padding_h_10">异常处理</span>
            </div>
            {{}}}

            {{if(it.oldstatus==2 && it.oldstatus!=3){}}
            <div class="col_4" onclick="location.href='<{url route='/business/person/pig-out' pigid=$pigid}>'">
                <span class="label_mx_green padding_h_10">出栏登记</span>
            </div>
            {{}}}

            {{if(it.oldstatus>=3){}}
            <div class="col_4" onclick="location.href='<{url route='/business/person/price-track' pigid=$pigid}>'">
                <span class="label_mx_green padding_h_10">价格跟踪</span>
            </div>
            {{}}}

            {{if(it.oldstatus==2 && it.oldstatus!=3){}}
            <div class="col_4 margin_b_10" onclick="location.href='<{url route='/business/person/disease' pigid=$pigid}>'">
                <span class="label_mx_green padding_h_10">疾病录入</span>
            </div>
            {{}}}
            {{}}}
            <div class="col_4 margin_b_10" onclick="location.href='<{url route='/business/person/upvideo' pigid=$pigid}>'">
                <span class="label_mx_green padding_h_10">视频录入</span>
            </div>

        </div>
        <div class="bg_white lineheight_4">
            <div class="arrow_down padding_h_15 border_b from_nav">档案</div>
            <div class="padding_15 font_12 lineheight_2 hide">
                <div class="">猪场合同编号：{{=it.contract_no}}</div>
                <!--<div class="">猪场：{{=it.slaughterhouse}}</div>-->
                <div class="">批次：{{=it.no}}</div>
                <div class="">代养地址：{{=it.address}}</div>
                <div class="flex_row_2">
                    <div class="row_one" data-str="f_img">
                        <div class="">父本编号:{{=it.f_no}}</div>
                        <a href="{{=it.f_img}}" class="fancybox"><img class="fit_img" src="{{=it.f_img}}" alt=""></a>
                    </div>
                    <div class="row_one" data-str="m_img">
                        <div class="">母本编号:{{=it.m_no}}</div>
                        <a href="{{=it.m_img}}" class="fancybox"><img class="fit_img" src="{{=it.m_img}}" alt=""></a>
                    </div>
                </div>
            </div>
            <div class="arrow_down padding_h_15 border_b from_nav">生长环境</div>
            <div class="padding_15 flex_row_4" style="display:none">
                {{for(var i=0;i<it.surroundings.length;i++){}}
                <div class="row_one surrounding_img" data-str="surroundings">
                    <a href="{{=it.surroundings[i]}}" class="fancybox"><img class="fit_img2" src="{{=it.surroundings[i]}}" alt=""></a>
                </div>
                {{}}}
            </div>
            <div class="arrow_down padding_h_15 border_b from_nav">巡检记录</div>
            <div class="padding_h_15 font_12 light hide">
                {{for(var i=0;i<it.records.length;i++){}}
                <div class="h_justify border_b" onclick="location.href='{{=it.records[i].url}}'">
                    <div>{{=it.records[i].title}}</div>
                    <div>第{{=it.records[i].no}}次巡检</div>
                    <div>巡检人：{{=it.records[i].who}}</div>
                </div>
                {{}}}
            </div>
            <div class="arrow_down padding_h_15 border_b from_nav">疫苗情况</div>
            <div class="padding_h_15 font_12 light hide lineheight_2">
                {{for(var i=0;i<it.vaccine.length;i++){}}
                <div class="padding_v_10 border_b">
                    <div>{{=it.vaccine[i].createtime}}</div>
                    <div>{{=it.vaccine[i].remark}}</div>
                </div>
                {{}}}
            </div>
            <div class="arrow_down padding_h_15 border_b from_nav">成本记录<span class="padding_l_15 danger">共{{=it.costs.length}}次，总计花费{{=it.totalcost}}元</span></div>
            <div class="padding_h_15 font_12 hide lineheight_2">
                {{for(var i=0;i<it.costs.length;i++){}}
                <div class="padding_v_10 border_b">
                    <div class="h_justify">
                        <div>{{=it.costs[i].title}}</div>
                        <div class="danger">{{=it.costs[i].price}}元</div>
                    </div>
                    <div class="light">{{=it.costs[i].content}}</div>
                </div>
                {{}}}
            </div>
        </div>
    </script>

    <script>
        // 轮播模版

        // 详情模版
        var detail = <{$detail}>;console.log(detail)
        var evaldetail = doT.template($("#detail_template").text());
        loaddata(".detail",evaldetail,detail)
        // 详情项打开关闭特效
        $(".from_nav").click(function(){
            $(this).toggleClass("arrow_down arrow_up").next().toggle()
        })
        // 头部
        loadheadbar("仔猪详情",1)
        console.log(detail);

        //点击预览图片
        $('.fancybox').fancybox({
            'titlePosition' : 'over',
            'cyclic'        : true,
            'height':500
        });

        //幻灯片
        var swiper = new Swiper('.swiper-container', {
            pagination: '.swiper-pagination',
            paginationClickable: true,
            paginationBulletRender: function (swiper, index, className) {
                return '<span class="' + className + '">' + (index + 1) + '</span>';
            }
        });


    </script>


